<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
	body {background: #78bc43;}
	#c1,span {background: yellow;}
	</style>
	<script type="text/javascript">
	window.onload = function () {
		var oC = document.getElementById('c1');
		var oGC = oC.getContext('2d');

		oGC.beginPath();
		oGC.moveTo(100,100);
		oGC.lineTo(200,200);
		oGC.lineWidth = 20;

		//oGC.lineCap = 'round';		//两端都向外伸展宽度的一半（半径，下同），即5px合计10px
		//oGC.lineCap = 'square';		//linCap的默认样式是butt

		oGC.stroke();
	}
	</script>
</head>
<body>
	<canvas id="c1" width="600" height="400"> <!-- 宽高在这里设置 -->
		<span>不支持canvas的浏览器</span>
	</canvas>
</body>
</html>